package com.coderknock.spring.boot.mybatis.blog;

import com.coderknock.spring.boot.mybatis.plugin.LogPlugin;
import com.coderknock.spring.boot.mybatis.typehandle.ArticleTypeHandle;
import org.apache.ibatis.session.Configuration;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@MapperScan("com.coderknock.spring.boot.mybatis.mapper")
public class BlogApplication {
    @Bean
    ConfigurationCustomizer mybatisConfigurationCustomizer() {
        return new ConfigurationCustomizer() {
            @Override
            public void customize(Configuration configuration) {
                configuration.addInterceptor(new LogPlugin());
                configuration.getTypeHandlerRegistry().register(ArticleTypeHandle.class);
            }
        };
    }

    public static void main(String[] args) {
        SpringApplication.run(BlogApplication.class, args);
    }
}
